#!/bin/sh
rm A*
rm B*
rm D*
rm G*
rm M*
rm N*
rm S*
ls
openssl req -x509 -new -nodes -keyout Master.key -out Master.cert -subj '/C=SW/CN=MasterCA'
while read LINE
do
	keytool -genkey -keystore ${LINE}.jks -alias ${LINE} -dname "CN=${LINE}" -keypass password -storepass password -noprompt
	keytool -certreq -alias ${LINE} -keystore ${LINE}.jks -file ${LINE}.csr -keypass password -storepass password -noprompt
	openssl x509 -req -in ${LINE}.csr -CA Master.cert -CAkey Master.key -CAcreateserial -out ${LINE}.cert
	keytool -importcert -alias root -file Master.cert -keystore ${LINE}.jks -keypass password -storepass password -noprompt
	keytool -importcert -alias ${LINE} -file ${LINE}.cert -keystore ${LINE}.jks -keypass password -storepass password -noprompt
done

exit 0